package com.zhangdi.demo.jdbc.vo;

import com.zhangdi.demo.jdbc.entity.Industry;
import com.zhangdi.demo.jdbc.tree.Node;

import java.util.ArrayList;
import java.util.List;

public class QVo extends Node<QVo> {
    public QVo(Industry dto) {
        setId(dto.getId());
        setName(dto.getName());
        setPid(dto.getParent_id());
        this.ids = new ArrayList<>();

        addChildren(dto);
    }

    private void addChildren(Industry parent) {
        if (null == parent.getChildren()) return;

        for (Industry child : parent.getChildren()) {
            QVo vo = new QVo(child);
            if (child.getLevelType() > 0) {
                vo.setLevel(true);
            }
            getChildren().add(vo);
        }
    }

    private boolean level = false;

    private List<Long> ids;

    public boolean isLevel() {
        return level;
    }

    public void setLevel(boolean level) {
        this.level = level;
    }

    public List<Long> getIds() {
        return ids;
    }

    public void setIds(List<Long> ids) {
        this.ids = ids;
    }
}
